package org.hbgl.geoentity.db.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;

/**
 * 代码功能：
 * 开发日期：2022/5/5
 * 作者：蒋海仑
 * 联系方式：
 * 版本更迭说明：
 * 版权信息：河北广联信息技术有限公司
 */
@Data
public class NodeVo {
    private Integer id;
    private Integer nodeId;
    private Integer unitId;
    private String appKey;
    private String appSecret;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDateTime authDate;
    private Integer state;
    private Integer examState;
    private Integer authState;
    private LocalDateTime addTime;
    private LocalDateTime editTime;
    private String nodeIdcode;
    private String nodeIdcodePrefix;
    private String nodeIdcodeSuffix;
    private Integer nodeLevel;
    private String nodeProfile;
    private String remark;
    private Integer nodeType;
    private String nodeName;
    private String contractAgreement;
    private String unitName;
    private String unitCode;
    private String unitAddress;
    private String provinceCode;
    private String cityCode;
    private String areaCode;
    private String unitType;
    private Integer tradeId;
    private String license;
    private String email;
    private String linkman;
    private String linkphone;
    private String provinceName;
    private String cityName;
    private String areaName;
    private String unitTypeName;
    private String tradeName;

    private Integer ipType;
    private String ip;
    private String udpPort;
    private String tcpPort;
    private String httpPort;
    private String authFile;

    private Integer authExamineState;
    private LocalDateTime authExamTime;
    private LocalDateTime examTime;

    public String getNodeIdcodePrefix() {
        if (StringUtils.isBlank(nodeIdcodePrefix) && StringUtils.isNotBlank(nodeIdcode)) {
            if(nodeIdcode.length()<8) {
                nodeIdcodePrefix = nodeIdcode;
            }else {
                nodeIdcodePrefix = nodeIdcode.substring(0, 8);
            }

        }
        return nodeIdcodePrefix;
    }

    public String getNodeIdcodeSuffix() {
        if (StringUtils.isBlank(nodeIdcodeSuffix) && StringUtils.isNotBlank(nodeIdcode)) {
            if(nodeIdcode.length()>=8) {
                nodeIdcodeSuffix = nodeIdcode.substring(8);
            }else {
                nodeIdcodePrefix = "";
            }

        }
        return nodeIdcodeSuffix;
    }
}
